namespace WebApplication2.Models
{
    using System;
    using System.Data.Entity;
    using System.ComponentModel.DataAnnotations.Schema;
    using System.Linq;

    public partial class studentModel : DbContext
    {
        public studentModel()
            : base("name=studentModel")
        {
        }

        public virtual DbSet<classInfo> classInfo { get; set; }
        public virtual DbSet<stuInfo> stuInfo { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Entity<classInfo>()
                .Property(e => e.className)
                .IsUnicode(false);

            modelBuilder.Entity<classInfo>()
                .HasMany(e => e.stuInfo)
                .WithOptional(e => e.classInfo)
                .HasForeignKey(e => e.FK_classID);

            modelBuilder.Entity<stuInfo>()
                .Property(e => e.Name)
                .IsUnicode(false);

            modelBuilder.Entity<stuInfo>()
                .Property(e => e.Sex)
                .IsFixedLength()
                .IsUnicode(false);
        }
    }
}
